

#pragma once

#include <sstream>

namespace Den{

    template<class T> struct support_sstream
    {
        typedef char (&No)[1]; typedef char (&Yes)[2];

        template<class U> static U& ref();
        template<class U> static U  val();

        #ifdef _MSC_VER
        template<class U>
            static Yes HelpMe( decltype( ref<::std::stringstream>() << val<U>()  )*  );
        #else
        template<class U>
            static Yes HelpMe(char(*)[sizeof(ref<::std::stringstream>() << val<U>())]);
        #endif

        template<class U>
            static No HelpMe(...);


        enum { value = sizeof(HelpMe<T>(0)) == sizeof(Yes) };
    };

}//namespace Den


#if 0

#include <den/meta/support_sstream.h>

struct some{};
struct rabbit{};

::std::sstream& operator<< (::std::stringstream& ss, const rabbit&) { return ss; }

struct rabbit1
{
    template<class T> friend T&
           operator<<(T& os, const rabbit1&){ return os; }
};

int main()
{
    std::cout << "Hello, world!\n";
    std::cout << "can cout<<int(1) ? (must be true): "<< support_sstream<int>::value<<std::endl;
    std::cout << "can cout<<float(1.0f) ? (must be true): "<< support_sstream<float>::value<<std::endl;

    some s;
    std::cout << "can cout<< s ? (must be false): "<< support_sstream<some>::value<<std::endl;

    rabbit r;
    std::cout << "can cout<< r ? (must be true): "<< support_sstream<rabbit>::value<<std::endl;

    rabbit1 r1;
    std::cout << "can cout<< r1 ? (must be true): "<< support_sstream<rabbit1>::value<<std::endl;

}

#endif



